package ModelLayer;

import java.util.ArrayList;
import java.util.Iterator;

/**
 *
 */
public class DVDCon {
    private static DVDCon instance = new DVDCon();
    private ArrayList<DVD> DVDTitles;

    private DVDCon() {
        if (DVDTitles == null) DVDTitles = new ArrayList<DVD>();
    }

    public static DVDCon getInstance() {
        return instance;
    }

    public ArrayList<DVD> get() {
        return DVDTitles;
    }

    public void set(ArrayList<DVD> newDVD) {
        DVDTitles = newDVD;
    }

    public void add(DVD newDVD) {
        DVDTitles.add(newDVD);
    }

    /*public void addDVD(DVD dvd){DVDCollection.add(dvd);}

    public void removeByTitle(String title){
    Iterator <DVD> dvd = DVDCollection.iterator();
    while (dvd.hasNext()){
    DVD d = dvd.next();
    if(d.getTitle().equals(title) ){
    DVDCollection.remove(d);
    return;
    }
    }
    }
    */
/*    public void removeById(int id) {
        Iterator<DVD> dvd = DVDTitles.iterator();
        while (dvd.hasNext()) {
            DVD d = dvd.next();
            if (d.getId() == id) {
                DVDTitles.remove(d);
                System.out.println("DVD removed.");
                return;
            }
        }
        System.out.println("Not found.");
    }*/
    /*
    public DVD getById(int id) {
        for (int i = 0; i < this.DVDCollection.size(); i++) {
            DVD current_dvd = this.DVDCollection.get(i);
            if (current_dvd.getId() == id) return current_dvd;
        }
        // TODO
        // If so far .. Throw exception "DVD not found"
        //this.DVDCollection
        return null;
    }

    */
}
